<template>
  <div class="selectParameter">
    <dialogPublic
      title="选择设备参数"
      :show.sync="showDialong"
      @doSubmit="doSave"
      @doClose="doClose"
      appendTobody
      class="moveNodeSelecet"
    >
      <editForm :formConfig="paramConfig" ref="paramForm" :formData="paramData"></editForm>
    </dialogPublic>
  </div>
</template>

<script>
import { getEquipment } from "@/api/equipmentLedger/equipmentManage";
export default {
  components: {},
  props: {
    paramData: {
      type: Object,
      default: () => {
        return {};
      }
    },
    equipmentParam: {
      type: Array,
      default: () => {
        return [];
      }
    },
    currentDevice: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  watch: {
    formData: {
      handler: function(val) {
        this.treeSetting.treeData = val;
      },
      deep: true
    }
  },
  name: "editDialog",
  data() {
    return {
      chooseDataList: [],
      showDialong: true,
      haveRemark: true,
      showCheckbox: true,
      showTree: false,
      hideBtn: true,
      paramConfig: {
        itemArr: [
          {
            type: "select",
            label: "设备",
            prop: "major",
            required: true,
            selectOption: [],
            span: 24
          },
          {
            type: "select",
            label: "异动参数",
            prop: "major",
            required: true,
            selectOption: [],
            span: 24
          },
          {
            type: "text",
            label: "改前值",
            prop: "major",
            disabled:true,
            span: 24
          },
          {
            type: "text",
            label: "改后值",
            prop: "major",
            span: 24
          }
        ]
      }
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      // let listData = [];
      // this.chooseData.map((i, index) => {
      //   listData.push(i.paramId);
      // });
      // this.getEquipmentParam();
    },
    getEquipmentParam() {
      let basis = [];
      getEquipment(this.currentDevice.id).then(res => {
        // let existArr = [];
        // let data = res.data;
        // if (data.paramsList) {
        //   data.paramsList.map(i => {
        //     i.paramOld = i.paramValue;
        //     i.paramNew = "";
        //     basis.push(i);
        //   });
        // }
        // let str = this.chooseDataList.toString();
        // let endBasis = [];
        // basis.map(i => {
        //   if (this.chooseDataList.includes(i.paramId)) {
        //     for (let j in this.chooseData) {
        //       if (this.chooseData[j].paramId == i.paramId) {
        //         i = Object.assign(i, this.chooseData[j]);
        //         endBasis.push(i);
        //         break;
        //       }
        //     }
        //   } else {
        //     endBasis.push(i);
        //   }
        // });
      });
    },
    doClose() {
      this.$emit("update:showSelete", false);
    },
    doSave() {
      

      this.$emit("changeSelete", arr);
      this.doClose();
    }
  }
};
</script>

<style lang='less'>
.moveNodeSelecet {
  .el-dialog__body {
    height: 400px !important;
  }
  // height: 70% !important;
}
</style>